home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programmierung
/
Power-Programmierung CD 2 (Tewi)(1994).iso
/
c
/
interpre
/
proxy
/
merge.prx
< prev
next >
Wrap
Text File
|
1992-05-09
|
591b
|
20 lines
eos="eos";
ch1=channel();
ch2=channel();
ch3=channel();
task merge(inp1,inp2,out;x) {
n=0;
while (true) {
if(n==2) {out!eos;skip;}
if(avail(inp1)) {inp1?x;if(x==eos) n=n+1;
else out!x;}
if(avail(inp2)) {inp2?x;if(x==eos) n=n+1;
else out!x;}
}};
task source1(out) {out!1;out!3;out!eos;};
task source2(out) {out!2;out!4;out!5;out!eos;};
task sink(inp;x) {inp?x;while(x!=eos) {print x;inp?x;}};
task main() {start source1(ch1); start source2(ch2);start merge(ch1,ch2,ch3);
start sink(ch3);};
end